<?php

namespace App\Admin\Controllers;

use App\Services\TaskService;
use Encore\Admin\Controllers\AdminController;

class TaskController extends AdminController
{
    protected $taskService;

    public function __construct(
        TaskService $taskService
    ) {
        $this->taskService = $taskService;
    }


    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = '任务';

    /**
     * @return \Encore\Admin\Grid
     * @throws \Exception
     */
    protected function grid()
    {
        try {
            return $this->taskService->grid();
        } catch (\Exception $e) {
            throw $e;
        }
    }

    /**
     * @param $id
     * @return \Encore\Admin\Show|mixed
     * @throws \Exception
     */
    protected function detail($id)
    {
        try {
            return $this->taskService->detail($id);
        } catch (\Exception $e) {
            throw $e;
        }
    }

    /**
     * @return \Encore\Admin\Form
     * @throws \Exception
     */
    protected function form()
    {
        try {
            return $this->taskService->form();
        } catch (\Exception $e) {
            throw $e;
        }
    }
}
